//
//  UIBarButtonItem+Create.m
//  Weibo
//
//  Created by Justsoso on 16/4/25.
//  Copyright © 2016年 Justsoso. All rights reserved.
//

#import "UIBarButtonItem+Create.h"

@implementation UIBarButtonItem (Create)


+ (UIBarButtonItem *)createBarButtonItem:(NSString *)imageName
                                   target:(id)target
                                   action:(SEL)selector
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:[imageName stringByAppendingString:@"highlighted"]] forState:UIControlStateHighlighted];
    
    [btn addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    [btn sizeToFit];
    return [[UIBarButtonItem alloc] initWithCustomView:btn];
}

@end
